<template>
	<view class="paper-container">
		<!-- 标签栏 -->
		<view class="tab-bar">
			<view :class="['tab-item', { active: currentTab === 'fixed' }]" @click="currentTab = 'fixed'">固定试卷</view>
			<view :class="['tab-item', { active: currentTab === 'time' }]" @click="currentTab = 'time'">时段试卷</view>
		</view>
		<!-- 列表内容 -->
		<view class="paper-list" v-if="currentTab === 'fixed'">
			<view class="paper-item" v-for="item in fixedPaperList" :key="item.id">
				<view class="paper-name">{{item.name}}</view>
				<view class="paper-subject">{{item.subjectName}}</view>
				<text @click="goanswer" style="color: skyblue;">开始做题</text>
			</view>
			<view class="no-data" v-if="fixedPaperList.length === 0">暂无数据</view>
		</view>
		<view class="paper-list" v-else>
			<!-- 时段试卷列表逻辑类似，可按需替换数据 -->
			<view class="paper-item" v-for="item in timePaperList" :key="item.id">
				<view class="paper-name">{{item.name}}</view>
				<view class="paper-subject">{{item.subjectName}}</view>
				<text @click="goanswer" style="color: skyblue;">开始做题</text>
			</view>
			<view class="no-data" v-if="timePaperList.length === 0">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import http from '../../http';
	export default {
		data() {
			return {
				pagers:{
					paperType:1,
					subjectId:'1',
					pageIndex:1,
					pageSize:10
				},
				timepagers:{
					paperType:4,
					subjectId:'1',
					pageIndex:1,
					pageSize:10
				},
				currentTab: 'fixed',
				fixedPaperList: [],
				timePaperList: [] // 时段试卷数据，可根据实际接口返回填充
			};
		},
		methods: {
			getsubjectList(){
				http({
					url:'/api/student/education/subject/list',
					method:"post"
				}).then(res=>{
					console.log(res,'list');
				})
			},
			
			getfixedPaperList() {
				http({
					url: "/api/student/exam/paper/pageList",
					method: "post",
					data:this.pagers
				}).then(res => {
					console.log(res,"fixedpaper");
					if (res.code === 1) {
						this.fixedPaperList = res.response.list
					}
				})
			},
			getTimePaperList() {
				http({
					url: "/api/student/exam/paper/pageList",
					method: "post",
					data:this.timepagers
				}).then(res => {
					console.log(res,"timepaper");
					if (res.code === 1) {
						this.timePaperList = res.response.list
					}
				})
			},
			goanswer(){
					  uni.navigateTo({
					  	url:"/pages/answer/answer"
					  })
			},
		},
		onLoad(){
			this.getsubjectList()
			this.getfixedPaperList()
			this.getTimePaperList()
		}
	};
</script>

<style scoped>
	.paper-container {
		padding: 15rpx;
	}

	.tab-bar {
		display: flex;
		border-bottom: 1px solid #eee;
	}

	.tab-item {
		flex: 1;
		text-align: center;
		padding: 20rpx 0;
		font-size: 28rpx;
	}

	.tab-item.active {
		color: #007aff;
		border-bottom: 2px solid #007aff;
	}

	.paper-list {
		margin-top: 20rpx;
	}

	.paper-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 0;
		border-bottom: 1px solid #f5f5f5;
	}

	.paper-name {
		font-size: 28rpx;
		color: #333;
	}

	.paper-subject {
		font-size: 26rpx;
		color: #999;
	}

	.no-data {
		text-align: center;
		color: #999;
		padding: 50rpx 0;
	}
</style>